<!doctype html>
<html lang="en" class="fixed">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>预约试听</title>
    <link rel="apple-touch-icon" sizes="120x120" href="favicon/apple-icon-120x120.png">
    <link rel="icon" type="image/png" sizes="192x192" href="favicon/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/animate.css/animate.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.css')) ?>">
    <link rel="stylesheet"
          href="<?php xcho(loadSource('/assets/plugins/data-table/media/css/dataTables.bootstrap.min.css')) ?>">
    <!--    <link rel="stylesheet" href="-->
    <?php //xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?><!--">-->
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/metroStyle/metroStyle.css')) ?>"
          type="text/css">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/style.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/app.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
</head>

<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>
<div class="container-fluid">
    <div class="row" style="padding: 0">
        <form action="<?php xcho($sSearchAction) ?>" id="FormList">
            <div class="class-box">
                <div class="main-title">
                    <div class="layui-tab row" lay-filter="config" lay-allowClose="true">
                        <div class="layui-tab-title">
                            <input type="hidden" id="view_id" name="view_id" value="">
                            <ul class="col-md-8" style="display: inline-block;">
                                <?php if(!empty($aView)) {?>
                                    <?php foreach ($aView as $aTmp) {?>
                                        <li class="layui-this" lay-id="<?php xcho($aTmp['pk'])?>" ><?php xcho($aTmp['cfg_name'])?></li>
                                    <?php }?>
                                <?php }?>
                            </ul>
                            <div class="input-group col-md-4">
                                <input type="text" class="form-control" id="keyword" name="keyword" value="<?php xcho($aSearch['keyword']) ?>"
                                   placeholder="可搜索学员名、联系手机、亲戚手机">
                                <span class="input-group-btn">
                                    <input type="submit" url="<?php xcho($sSearchAction) ?>"class="btn btn-primary edit" value="搜索" /> 
                                </button>
                                </span>
                            </div> 
                        </div>
                        
                    </div>
                    <div class="row">
                        <div class="col-xs-6 col-sm-3 form-container form-inline">
                            <div class="form-group">
                                <label ">范围：</label>
                                <input results="s" class="form-control group-picker" id="scale_name" name="scale_name" type="search"
                                       value="<?php xcho($aSearch['scale_name']) ?>" url="<?php xcho($sSearchRange) ?>">
                                <input results="s" id="scale_type" name="scale_type" type="hidden"
                                       value="<?php xcho($aSearch['scale_type']) ?>">
                                <input results="s" id="scale_id" name="scale_id" type="hidden"
                                       value="<?php xcho($aSearch['scale_id']) ?>">
                            </div>
                            <div class="form-group">
                                <label>分配状态：</label>
                                <select id="assign_status" class="form-control" name="assign_status">
                                    <option value="">全部</option>
                                    <?php foreach ($aAssignList as $aTmp) { ?>
                                        <option value="<?php xcho($aTmp['dict_value']) ?>"
                                            <?php if ($aTmp['dict_value'] == $aSearch['assign_status']) { ?>
                                                selected="selected"
                                            <?php } ?>><?php xcho($aTmp['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label>考勤状态：</label>
                                <select name="attendance_status" class="form-control" id="attendance_status">
                                    <option value="">全部</option>
                                    <?php foreach ($aAttendanceList as $aTmp) { ?>
                                        <option value="<?php xcho($aTmp['dict_value']) ?>"
                                            <?php if ($aTmp['dict_value'] == $aSearch['attendance_status']) { ?>
                                                selected="selected"
                                            <?php } ?>><?php xcho($aTmp['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label>试听日期：</label>
                                <select class="form-control" id="start_date_type" name="start_date_type" lay-filter="start_date_type">
                                    <option value="">全部</option>
                                    <?php foreach ($aDateType as $aTmp) { ?>
                                        <option value="<?php xcho($aTmp['dict_value']) ?>"
                                            <?php if ($aTmp['dict_value'] == $aSearch['start_date_type']) { ?>
                                                selected="selected"
                                            <?php } ?>><?php xcho($aTmp['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                            <div class="form-group"> <!-- 注意：这一层元素并不是必须的 -->
                                <input type="text" class="form-control" id="begin_start_time" name="begin_start_time"
                                       value="<?php xcho($aSearch['begin_start_time']) ?>" placeholder="年/月/日">
                            </div>
                            <div class="form-group"> <!-- 注意：这一层元素并不是必须的 -->
                                <input type="text" class="form-control" id="end_start_time" name="end_start_time"
                                       value="<?php xcho($aSearch['end_start_time']) ?>" placeholder="年/月/日">
                            </div>
                        </div>
                        <div class="col-xs-6 col-sm-3 form-container form-inline">
                            <div class="form-group">
                                <label>教务确认：</label>
                                <select class="form-control" name="is_confirm" id="is_confirm">
                                    <option value="">全部</option>
                                    <?php foreach ($aConfirm as $aTmp) { ?>
                                        <option value="<?php xcho($aTmp['dict_value']) ?>"
                                            <?php if ($aTmp['dict_value'] == $aSearch['is_confirm']) { ?>
                                                selected="selected"
                                            <?php } ?>><?php xcho($aTmp['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label>科目：</label>
                                <select class="form-control" name="csubject" id="csubject">
                                    <option value="">全部</option>
                                    <?php foreach ($aSubject as $aTmp) { ?>
                                        <option value="<?php xcho($aTmp['dict_value']) ?>"
                                            <?php if ($aTmp['dict_value'] == $aSearch['csubject']) { ?>
                                                selected="selected"
                                            <?php } ?>><?php xcho($aTmp['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                            <div class="form-group">
                                <label>创建日期：</label>
                                <select id="add_date_type" class="form-control" name="add_date_type" lay-filter="add_date_type">
                                    <option value="">全部</option>
                                    <?php foreach ($aDateType as $aTmp) { ?>
                                        <option value="<?php xcho($aTmp['dict_value']) ?>"
                                            <?php if ($aTmp['dict_value'] == $aSearch['add_date_type']) { ?>
                                                selected="selected"
                                            <?php } ?>><?php xcho($aTmp['cn_name']) ?></option>
                                    <?php } ?>
                                </select>
                            </div>
                            <div class="form-group"> <!-- 注意：这一层元素并不是必须的 -->
                                <input type="text" class="form-control" id="begin_add_time" name="begin_add_time"
                                       value="<?php xcho($aSearch['begin_add_time']) ?>" placeholder="年/月/日">
                            </div>
                            <div class="form-group"> <!-- 注意：这一层元素并不是必须的 -->
                                <input type="text" class="form-control" id="end_add_time" name="end_add_time"
                                       value="<?php xcho($aSearch['end_add_time']) ?>" placeholder="年/月/日">
                                <input type="submit" url="<?php xcho($sSearchAction) ?>"class="btn btn-primary edit" value="搜索" />
                            </div>
                            <input type="text" name="orderby" value="<?php xcho($iOrderBy) ?>" style="display: none;">
                            <div>
                                <?php if(!empty($aChannel)){ ?>
                                <a href="#" id="toggle">渠道展开</a>
                                    <label>全选：<input type="checkbox" id="channelAll"></label>
                                <div id="content" style="display: none;">
                                <label>渠道：</label>
                                <div class="checkbox_channel">
                                    <?php foreach ($aChannel as  $aTmp) { ?>
                                        <label class="checkbox-inline">
                                            <input type="checkbox" title="checkbox_channel"
                                                   name="channel_id[]" <?php if (!empty($aSearch['channel_id'])
                                                && in_array($aTmp['id'],$aSearch['channel_id'])) { ?> checked="checked" <?php } ?>
                                                   value="<?php xcho($aTmp['id']) ?>"><?php xcho($aTmp['cn_name']) ?>
                                        </label>
                                    <?php } ?>
                                </div>
                                </div>
                                <?php } ?>
                            </div>
                        </div>
                        <ul class="btns-group">
                            <a href="javascript:;" class="btn btn-white" id="save_config">保存设置</a>
                            <a href="javascript:;" class="btn btn-primary" id="save_recover">恢复默认</a>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="class-box">
                <div class="class-box-title">
                    <h3>预约列表</h3>
                    <div class="class-box-tools">
                        <?php if (isset($aAction['excel_url'])) { ?>
                            <span class="btn btn-primary" id="excel" url="<?php xcho($aAction['excel_url']) ?>">导出</span>
                        <?php } ?>
                    </div>
                </div>
                <div class="from-top row">
                    <div class="from-top-left col-md-5">
                        <ul>
                            <?php if(isset($aActions['edittmk'])) { ?>
                            <li><span class="btn btn-primary" id="tmk">分配TMK</span></li>
                            <?php } ?>
                            <?php if(isset($aActions['editcc'])) { ?>
                            <li><span class="btn btn-primary" id="cc">分配CC</span></li>
                            <?php } ?>
                            <li class="dropdown">
                                <div class="top_more">
                                    <button type="button" class="btn btn-warning dropdown-toggle"
                                    data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
                                    aria-expanded="false">更多操作 <span class="caret"></span></button>
                                    <ul class="dropdown-menu">
                                        <?php if (isset($aActions['edits_url'])) { ?>
                                            <li>
                                                <a href="javascript:;" id="more_change" url="<?php xcho($aActions['edits_url']) ?>"
                                                urlSubmit="<?php xcho($aActions['saveList_url']) ?>">
                                                    批量修改
                                                </a>
                                            </li>
                                        <?php } ?>
                                        <?php if (isset($aActions['dels'])) { ?>
                                            <li>
                                                <a href="javascript:;" id="more_del"
                                                url="<?php xcho($aActions['dels']['dels_url']) ?>"
                                                actions="<?php xcho($aActions['dels']['actions']) ?>">批量删除
                                                </a>
                                            </li>
                                        <?php } ?>
                                    </ul>
                                </div>
                            </li>

                        </ul>
                    </div>
                </div>
                <div class="row pagination-wrap">
                    <div class="col-sm-6">

                        <div class="pagination-group col-sm-12">
                            <input class="form-control" type="number" min="1"
                                   max="<?php xcho($iMaxPage) ?>" name="now_page" placeholder="请输入页码"
                                   value="<?php xcho($iNowPage) ?>"/>
                            <span>共搜索到<?php xcho($iTotalNum) ?>条记录</span>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <ul class="pagination">
                            <?php xchoHtml($aOrderLessons->render()) ?>
                        </ul>
                    </div>
                </div>
                <div class="class-box-body">
                    <table class="layui-form table table-bordered table-hover table table-bordered table-striped" id="demo">
                        <thead>
                        <tr>
                            <th><input type="checkbox" lay-filter="allChoose" name="" lay-skin="primary"></th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;" href="<?php ($iOrderBy%2 && in_array($iOrderBy,[1,0]))?xcho($aOrderURLs[0]):xcho($aOrderURLs[1]);?>">主键
                                    <span style="position: absolute; top:-6px">
                                            <i class="upOrder glyphicon glyphicon-triangle-top" style="display:<?php $iOrderBy==1?xcho('none'):xcho('block');?>"></i><i class="dropOrder glyphicon glyphicon-triangle-bottom" style="display:<?php $iOrderBy==0?xcho('none'):xcho('block');?>"></i>
                                        </span>
                                </a>
                            </th>
                            <th>名称</th>
                            <th>新跟踪时间</th>
                            <th width="250px">最新跟踪记录</th>
                            <th>最新意向</th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;" href="<?php ($iOrderBy%2 && in_array($iOrderBy,[2,3]))?xcho($aOrderURLs[2]):xcho($aOrderURLs[3]);?>">TMK负责人
                                    <span style="position: absolute; top:-6px">
                                            <i class="upOrder glyphicon glyphicon-triangle-top" style="display:<?php $iOrderBy==3?xcho('none'):xcho('block');?>"></i><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:<?php $iOrderBy==2?xcho('none'):xcho('block');?>"></i>
                                        </span>
                                </a>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;" href="<?php ($iOrderBy%2 && in_array($iOrderBy,[4,5]))?xcho($aOrderURLs[4]):xcho($aOrderURLs[5]);?>">CC负责人
                                    <span style="position: absolute; top:-6px">
                                            <i class="upOrder glyphicon glyphicon-triangle-top" style="display:<?php $iOrderBy==5?xcho('none'):xcho('block');?>"></i><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:<?php $iOrderBy==4?xcho('none'):xcho('block');?>"></i>
                                        </span>
                                </a>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;" href="<?php ($iOrderBy%2 && in_array($iOrderBy,[6,7]))?xcho($aOrderURLs[6]):xcho($aOrderURLs[7]);?>">渠道来源
                                    <span style="position: absolute; top:-6px">
                                            <i class="upOrder glyphicon glyphicon-triangle-top" style="display:<?php $iOrderBy==7?xcho('none'):xcho('block');?>"></i><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:<?php $iOrderBy==6?xcho('none'):xcho('block');?>"></i>
                                        </span>
                                </a>
                            </th>
                            <th>年级</th>
                            <th>科目</th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;" href="<?php ($iOrderBy%2 && in_array($iOrderBy,[8,9]))?xcho($aOrderURLs[8]):xcho($aOrderURLs[9]);?>">课程
                                    <span style="position: absolute; top:-6px">
                                            <i class="upOrder glyphicon glyphicon-triangle-top" style="display:<?php $iOrderBy==9?xcho('none'):xcho('block');?>"></i><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:<?php $iOrderBy==8?xcho('none'):xcho('block');?>"></i>
                                        </span>
                                </a>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;" href="<?php ($iOrderBy%2 && in_array($iOrderBy,[10,11]))?xcho($aOrderURLs[10]):xcho($aOrderURLs[11]);?>">教师
                                    <span style="position: absolute; top:-6px">
                                            <i class="upOrder glyphicon glyphicon-triangle-top" style="display:<?php $iOrderBy==11?xcho('none'):xcho('block');?>"></i><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:<?php $iOrderBy==10?xcho('none'):xcho('block');?>"></i>
                                        </span>
                                </a>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;" href="<?php ($iOrderBy%2 && in_array($iOrderBy,[12,13]))?xcho($aOrderURLs[12]):xcho($aOrderURLs[13]);?>">试听时间
                                    <span style="position: absolute; top:-6px">
                                            <i class="upOrder glyphicon glyphicon-triangle-top" style="display:<?php $iOrderBy==13?xcho('none'):xcho('block');?>"></i><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:<?php $iOrderBy==12?xcho('none'):xcho('block');?>"></i>
                                        </span>
                                </a>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;" href="<?php ($iOrderBy%2 && in_array($iOrderBy,[14,15]))?xcho($aOrderURLs[14]):xcho($aOrderURLs[15]);?>">考勤状态
                                    <span style="position: absolute; top:-6px">
                                            <i class="upOrder glyphicon glyphicon-triangle-top" style="display:<?php $iOrderBy==15?xcho('none'):xcho('block');?>"></i><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:<?php $iOrderBy==14?xcho('none'):xcho('block');?>"></i>
                                        </span>
                                </a>
                            </th>
                            <th style="cursor: pointer;">
                                <a style="position: relative;" href="<?php ($iOrderBy%2 && in_array($iOrderBy,[16,17]))?xcho($aOrderURLs[16]):xcho($aOrderURLs[17]);?>">教务确认
                                    <span style="position: absolute; top:-6px">
                                            <i class="upOrder glyphicon glyphicon-triangle-top" style="display:<?php $iOrderBy==17?xcho('none'):xcho('block');?>"></i><i class="dropOrder glyphicon glyphicon-triangle-bottom"style="display:<?php $iOrderBy==16?xcho('none'):xcho('block');?>"></i>
                                        </span>
                                </a>
                            </th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($aOrderLessons as $aKey) { ?>
                            <?php foreach ($aReserveLessons as $aReserveLesson) { ?>
                                <?php if ($aReserveLesson['id'] == $aKey['id']) { ?>
                                    <tr>
                                        <td>
                                            <input type="checkbox" name="<?php xcho($aReserveLesson['id']) ?>"
                                                   lay-skin="primary" id="<?php xcho($aReserveLesson['id']) ?>"
                                                   sutdent_id="<?php xcho($aReserveLesson['student_id']) ?>">
                                        </td>
                                        <td>
                                            <?php xcho($aReserveLesson['id'])?>
                                        </td>
                                        <td>
                                            <a href="<?php xcho($aReserveLesson['student_url']) ?>">
                                                <?php xcho($aReserveLesson['sname']??'') ?>
                                            </a>
                                        </td>
                                        <td><?php xcho($aReserveLesson['ftime']??'') ?></td>
                                        <td><?php xcho($aReserveLesson['fresult']??'') ?></td>
                                        <td><?php xcho($aReserveLesson['intention']??'') ?></td>
                                        <td><?php xcho($aReserveLesson['tmk_name']??'') ?></td>
                                        <td><?php xcho($aReserveLesson['cc_name']??'') ?></td>
                                        <td><?php xcho($aReserveLesson['channel_name']??'') ?></td>
                                        <td><?php xcho($aReserveLesson['gradeStr']??'') ?></td>
                                        <td><?php xcho($aReserveLesson['csubject']??'') ?></td>
                                        <td>
                                            <a href="<?php xcho($aReserveLesson['course_url']) ?>">
                                                <?php xcho($aReserveLesson['cname']??'') ?>
                                            </a>
                                        </td>
                                        <td>
                                            <a href="<?php xcho($aReserveLesson['teacher_url']) ?>">
                                                <?php xcho($aReserveLesson['tname']??'') ?>
                                            </a>
                                        </td>
                                        <td>
                                            <?php xcho($aReserveLesson['reserve_time']??'') ?>
                                        </td>
                                        <td>
                                            <?php xcho($aReserveLesson['student_attendance_status']??'') ?>
                                        </td>
                                        <td><?php xcho($aReserveLesson['is_confirm']??'') ?></td>
                                        <td><?php xcho($aReserveLesson['add_time']??'') ?></td>
                                        <td>
                                            <?php if (isset($aReserveLesson['edit_url'])) { ?>
                                                <a class="btn btn-primary edit" lay-event="edit"
                                                   href="<?php xcho($aReserveLesson['edit_url']) ?>">
                                                    编辑
                                                </a>
                                            <?php } ?>
                                            <?php if (isset($aReserveLesson['del'])) { ?>
                                                <a class="btn btn-sub delete"
                                                   lay-event="del"
                                                   url="<?php xcho($aReserveLesson['del']['del_url']); ?>"
                                                   keyid="<?php xcho($aReserveLesson['id']) ?>"
                                                   actions="<?php xcho($aReserveLesson['del']['actions']) ?>">
                                                    删除
                                                </a>
                                            <?php } ?>
                                        </td>
                                    </tr>
                                <?php } ?>
                            <?php } ?>
                        <?php } ?>
                        </tbody>
                    </table>

                </div>
            </div>
        </form>
    </div>
</div>
</div>
<!--查看范围-->
<div class="modal fade" id="info-modal-group" tabindex="-1" role="dialog" aria-labelledby="modal-info-label">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-info">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>
            </div>
            <div class="modal-body" style="min-height: 150px;">
                <div class="form-group">
                    <input class="form-control" id="treeDemoinput" type="text">
                </div>
                <ul id="treeDemo" class="ztree">
                    <!--<option value="">全部</option>
                    <option value="all">所有学员</option>
                    <option value="mine">我的学员</option>
                    <option value="follower">下属的学员</option>
                    <option value="create">下属的学员</option>-->
                </ul>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="sureGroup" data-dismiss="modal">确定</button>
                <button type="button" class="btn btn-default" id="returnGroup" data-dismiss="modal">返回</button>
            </div>
        </div>
    </div>
</div>
<!--分配TMK-->
<div class="modal fade" id="tmk-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>选择负责人</h4>
            </div>
            <div class="form-group">
                <input class="form-control" id="tmklistinput" type="text">
            </div>
            <div class="modal-body ztree" id="tmklist">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="suretmk" data-dismiss="modal">　保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<!--分配CC-->
<div class="modal fade" id="cc-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>选择负责人</h4>
            </div>
            <div class="form-group">
                <input class="form-control" id="cclistinput" type="text">
            </div>
            <div class="modal-body ztree" id="cclist">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="surecc" data-dismiss="modal">　保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="config-modal" tabindex="-1" role="dialog" aria-labelledby="modal-primary-label"
     style="z-index:9999;display: none;">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="modal-primary-label"><i class="fa fa-user"></i>自定义快捷视图</h4>
            </div>
            <div class="modal-body layui-form" style="min-height: 150px;">
                <?php if(isset($aActions['config']) && $aActions['config'] == 'Y') {?>
                    <div class="form-group">
                        <label>是否公用</label>
                        <div class="layui-input-block">
                            <select id="is_public" name="is_public" lay-verify="required">
                                <?php foreach ($aConfirm as $aTmp) { ?>
                                    <option value="<?php xcho($aTmp['dict_value']) ?>"><?php xcho($aTmp['cn_name']) ?></option>
                                <?php } ?>
                            </select>
                        </div>
                    </div>
                <?php }?>
                <div class="form-group">
                    <label>快捷视图标题</label>
                    <div class="layui-input-block">
                        <input type="text" id="cfg_name" name="cfg_name" required
                               lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                        <input type="hidden" id="module" name="module" value="<?php xcho($sControllerModule)?>">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <span type="button" class="btn btn-primary" id="sureConfig" data-dismiss="modal" url="<?php xcho($saveConfig)?>">保存</span>
                <span type="button" class="btn btn-default" data-dismiss="modal">关闭</span>
            </div>
        </div>
    </div>
</div>
<div id="modalbox"></div>
<!--批量修改-->
<div id="yuyue_modal">
    <select name="quickedit_field" class="small" style="width: 100%">
        <!-- <option>请选择</option>
         <option value="courseName" relvalue="1">课程名称</option>
        -->
    </select>
    <div class="up_area" style="width: 100%;margin-top: 20px;">
        <!--<div id="quickedit_field0" style="display: none;">&nbsp;</div>
        <div id="quickedit_field_courseName" uitype="1" style="display: none;">
            <input type="text" tabindex="1" name="quickedit_value_courseName" id="courseName" value=""
                   class="detailedViewTextBox">
        </div>-->
    </div>
</div>
<input type="hidden" name="tmklist" value="<?php xcho($tmkList) ?>">
<input type="hidden" name="cclist" value="<?php xcho($ccList) ?>">
<input type="hidden" name="editTMK" value="<?php xcho($editTMK) ?>">
<input type="hidden" name="editCC" value="<?php xcho($editCC) ?>">
<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/jquery.dataTables.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/dataTables.bootstrap.min.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/dataTables.responsive.min.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/responsive.bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script>

    $(function () {
        $("#toggle").click(function() {
            $(this).text($("#content").is(":hidden") ? "渠道收起" : "渠道展开");
            $("#content").slideToggle();
        });
    })
    layui.use(['layer', 'form', 'laydate'], function () {
        var layer = layui.layer
            , form = layui.form;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#begin_start_time' //指定元素
        });
        laydate.render({
            elem: '#end_start_time' //指定元素
        });
        laydate.render({
            elem: '#begin_add_time' //指定元素
        });
        laydate.render({
            elem: '#end_add_time' //指定元素
        });

        form.on('checkbox(allChoose)', function (data) {
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function (index, item) {
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        form.on('checkbox(itemChoose)', function (data) {
            var sib = $(data.elem).parents('table').find('tbody input[type="checkbox"]:checked').length;
            var total = $(data.elem).parents('table').find('tbody input[type="checkbox"]').length;
            if (sib == total) {
                $(data.elem).parents('table').find('thead input[type="checkbox"]').prop("checked", true);
                form.render();
            } else {
                $(data.elem).parents('table').find('thead input[type="checkbox"]').prop("checked", false);
                form.render();
            }
        });
        var element = layui.element;

        //监听Tab切换，以改变地址hash值
        element.on('tab(config)', function(){
            $("#view_id").val(this.getAttribute('lay-id'));
            var view_all = $("#view_id").val();
            if(view_all == "nomal"){
                $("#FormList").find('input[type=text],select').each(function(){
                  $(this).val('');
                });
                $("#FormList").find('input[type=checkbox]').each(function(){
                  $(this).attr('checked',false);
                });            }
            $('#FormList').submit();
        });
        $("#channelAll").click(function(){
            var ischecked = $(this).is(':checked');
            var child = $(".checkbox_channel").find('input[type=checkbox]');
            child.each(function(index, item){
                item.checked = ischecked;
            });
        });
        /*element.on('tabDelete(config)', function(data){
            console.log(this); //当前Tab标题所在的原始DOM元素
            console.log(data.index); //得到当前Tab的所在下标
            console.log(data.elem); //得到当前的Tab大容器
            debugger;
        });*/
    });
    $("#start_date_type").on("change",function () {
        var ddVal = $(this).val();
        if(ddVal == "define" || ddVal == ''){
            $("#begin_start_time").val("");
            $("#end_start_time").val("");
        }else{
            var aDate = getDates(ddVal);
            $("#begin_start_time").val(aDate['sStartDate']);
            $("#end_start_time").val(aDate['sEndDate']);
        }
    })
    $("#add_date_type").on("change",function () {
        var ddVal = $(this).val();
        if(ddVal == "define" || ddVal == ''){
            $("#begin_add_time").val("");
            $("#end_add_time").val("");
        }else{
            var aDate = getDates(ddVal);
            $("#begin_add_time").val(aDate['sStartDate']);
            $("#end_add_time").val(aDate['sEndDate']);
        }
    })
    $(".layui-tab-close").on('click',function () {
        $.ajax({
            url: "<?php xcho($sDelView)?>",
            data: {
                id: $(this).parent().attr('lay-id')
            },
            type: 'post',
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    layer.alert("删除成功!")
                } else {
                    alert(data.msg);
                }
            },
            complete: function () {
                location.reload();
            },
            error: function () {

            }
        });
    });

    //显示保存快捷视图
    $("#save_config").on("click", function () {

        $('#config-modal').modal({
            keyboard: false,
            backdrop: false
        });
        $("#select-picker").focus(function () {
            $('#config-modal').modal({
                keyboard: false,
                backdrop: false
            });
        });
    })

    //保存视图
    $("#sureConfig").on("click", function () {
        var aArrData = new Array();
        var channelids=[];
        $('.checkbox_channel').find("input[title='checkbox_channel']:checked").each(function () {
            channelids.push($(this).val());
        });
        aArrData = {
            'is_public':$("#is_public").val(),
            'cfg_name':$("#cfg_name").val(),
            'module':$("#module").val(),
            'cfg_value':{
                'scale_name':$("#scale_name").val(),
                'scale_type':$("#scale_type").val(),
                'scale_id':$("#scale_id").val(),
                'assign_status':$("#assign_status").val(),
                'attendance_status':$("#attendance_status").val(),
                'channel_id':channelids,
                'is_confirm':$("#is_confirm").val(),
                'csubject':$("#csubject").val(),
                'start_date_type':$("#start_date_type").val(),
                'add_date_type':$("#add_date_type").val(),
                'keyword':$("#keyword").val(),
            }
        };
        $.ajax({
            url: $("#sureConfig").attr('url'),
            type: 'post',
            data: aArrData,
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    location.reload();
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
    })

    //恢复默认视图
    $("#save_recover").on("click", function () {
        var aArrData = new Array();

        $.ajax({
            url: "<?php xcho($sRestoreView)?>",
            type: 'post',
            data: {
                'module':$("#module").val(),
            },
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    location.reload();
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
    })
    //自动获取课程日期或者收费日期
    function getDates(sDateType) {
        var aDate = new Array();
        aDate['sStartDate'] = '';
        aDate['sEndDate'] = '';
        switch (sDateType){
            case 'month':
                aDate['sStartDate'] = '<?php $BeginDate = date("Y-m-01", strtotime(date("Y-m-d"))); xcho($BeginDate)?>';
                aDate['sEndDate'] = '<?php xcho(date("Y-m-d", strtotime("$BeginDate +1 month -1 day")))?>';
                break;
            case 'sevenday':
                aDate['sStartDate'] = '<?php xcho( date("Y-m-d", strtotime("-7 days")))?>';
                aDate['sEndDate'] = '<?php xcho( date("Y-m-d", strtotime("-1 days")))?>';
                break;
            case 'thirtyday':
                aDate['sStartDate'] = '<?php xcho( date("Y-m-d", strtotime("-30 days")))?>';
                aDate['sEndDate'] = '<?php xcho( date("Y-m-d", strtotime("-1 days")))?>';
                break;
            case 'today':
                aDate['sStartDate'] = '<?php xcho( date("Y-m-d"))?>';
                aDate['sEndDate'] = '<?php xcho( date("Y-m-d"))?>';
                break;
            case 'week':
                aDate['sStartDate'] = '<?php xcho( date("Y-m-d",strtotime("this week")))?>';
                aDate['sEndDate'] = '<?php xcho( date("Y-m-d",strtotime("this week +6 day")))?>';
                break;
            default:
                aDate['sStartDate'] = '<?php xcho( date("Y-m-d", strtotime("-1 days")))?>';
                aDate['sEndDate'] = '<?php xcho( date("Y-m-d", strtotime("-1 days")))?>';
                break;
        }
        return aDate;
    }
    // $(".top_more").hover(function () {
    //     $(this).find("ul").show();
    // }, function () {
    //     $(this).find("ul").hide();
    // });
    //获取焦点是显示查看范围弹框
    $(".group-picker").focus(function () {
        $('#info-modal-group').modal({
            keyboard: false,
            backdrop: false
        });
        $('#info-modal-group').on('shown.bs.modal', function (e) {
            // 关键代码，如没将modal设置为 block，则$modala_dialog.height() 为零
            $(this).css('display', 'block');
            $(this).find('.modal-dialog').css({
                'margin-top': "100px"
            });
        });
    });
    var setting = {
        view: {
            selectedMulti: false,
            addHoverDom: addHoverDom,
            removeHoverDom: removeHoverDom
        },
        edit: {
            enable: true
        },
        data: {
            keep: {
                parent: true,
                leaf: true
            },
            simpleData: {
                enable: true
            }
        },
        callback: {
            beforeDrag: beforeDrag,
            beforeRemove: beforeRemove,
//          beforeRename: beforeRename,
            onRemove: onRemove,
            onClick: zTreeOnClick
        }
    };
    var settingGroup = {
        view: {
            selectedMulti: false
        },
        edit: {
            enable: false
        },
        data: {
            keep: {
                parent: true,
                leaf: true
            },
            simpleData: {
                enable: true
            }
        }
    };
    var log, className = "dark";
    function beforeDrag(treeId, treeNodes) {
        return false;
    }
    //选中赋值到input中
    function zTreeOnClick(event, treeId, treeNode) {
        // alert(treeNode.tId + "," + treeNode.name);
        $(".group-picker").val(treeNode.name);
        $("#scale_type").val(treeNode.scale_type);
        $("#scale_id").val(treeNode.id);
    }
    function beforeRemove(treeId, treeNode) {
        className = (className === "dark" ? "" : "dark");
        //console.log("[ beforeRemove ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name);
        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
        zTree.selectNode(treeNode);
        return confirm("确认删除 " + treeNode.name + " 吗？");
    }
    var IDMark_Switch = "_switch",
        IDMark_Icon = "_ico",
        IDMark_Span = "_span",
        IDMark_Input = "_input",
        IDMark_Check = "_check",
        IDMark_Edit = "_edit",
        IDMark_Remove = "_remove",
        IDMark_Ul = "_ul",
        IDMark_A = "_a";
    function addHoverDom(treeId, treeNode) {
        if (treeNode.parentNode && treeNode.parentNode.id != 1) return;
        var aObj = $("#" + treeNode.tId + IDMark_A);
        if ($("#diyBtn_" + treeNode.id).length > 0) return;
        var editStr = "<a id='diyBtn_" + treeNode.id + "' title='" + treeNode.name + "' onfocus='this.blur();'>编辑</a>";
        aObj.append(editStr);
        var btn = $("#diyBtn_" + treeNode.id);
        if (btn) btn.bind("click", function () {
            editNode(treeNode)
        });

    }
    function removeHoverDom(treeId, treeNode) {
        $("#diyBtn_" + treeNode.id).unbind().remove();
        $("#diyBtn_space_" + treeNode.id).unbind().remove();
    };
    function onRemove(e, treeId, treeNode) {
        //console.log("onRemove ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.id);
        $.ajax({
            url: $("input[name='del_group_info']").val(),
            data: {
                id: treeNode.id
            },
            type: 'post',
            dataType: 'json',
            success: function (data) {
                //console.log(data)
                if (data.success == 1) {
                    layer.alert("删除成功!")
                } else {
                    alert(data.msg);
                }
            },
            complete: function () {
                location.reload();
            },
            error: function () {

            }
        });
    }
    function beforeRename(treeId, treeNode, newName) {
//            if (newName.length == 0) {
//                alert("节点名称不能为空.");
//                var zTree = $.fn.zTree.getZTreeObj("treeDemo");
//                setTimeout(function(){zTree.editName(treeNode)}, 10);
//                return false;
//            }
        editNode(treeNode);
        return true;
    }

    var newCount = 1;
    function add(e) {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            isParent = e.data.isParent,
            nodes = zTree.getSelectedNodes(),
            treeNode = nodes[0];
        if (treeNode) {
            treeNode = zTree.addNodes(treeNode, {
                id: (100 + newCount),
                pId: treeNode.id,
                isParent: isParent,
                name: "new node" + (newCount++)
            });
        } else {
            treeNode = zTree.addNodes(null, {
                id: (100 + newCount),
                pId: 0,
                isParent: isParent,
                name: "new node" + (newCount++)
            });
        }
        if (treeNode) {
            zTree.editName(treeNode[0]);
        } else {
            layer.alert("叶子节点被锁定，无法增加子节点");
        }
    };
    function edit() {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            nodes = zTree.getSelectedNodes(),
            treeNode = nodes[0];
        if (nodes.length == 0) {
            layer.alert("请先选择一个节点");
            return;
        }
        zTree.editName(treeNode);
    };
    function remove(e) {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            nodes = zTree.getSelectedNodes(),
            treeNode = nodes[0];
        if (nodes.length == 0) {
            layer.alert("请先选择一个节点");
            return;
        }
        var callbackFlag = $("#callbackTrigger").attr("checked");
        zTree.removeNode(treeNode, callbackFlag);
    };
    function setEdit() {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            remove = $("#remove").attr("checked"),
            removeTitle = $.trim($("#removeTitle").get(0).value);
        zTree.setting.edit.showRemoveBtn = remove;
//            zTree.setting.edit.showRenameBtn = rename;
        zTree.setting.edit.removeTitle = removeTitle;
//            zTree.setting.edit.renameTitle = renameTitle;
    }
    function clearChildren(e) {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            nodes = zTree.getSelectedNodes(),
            treeNode = nodes[0];
        if (nodes.length == 0 || !nodes[0].isParent) {
            alert("请先选择一个父节点");
            return;
        }
        zTree.removeChildNodes(treeNode);
    };
    $(document).ready(function () {
        onLoadZTree();
    });
    function onLoadZTree() {
        var treeNodes;
        $.ajax({
            url: $(".group-picker").attr('url'),
            type: 'get',
            async: false,
            dataType: 'json',
            success: function (data) {
                treeNodes = data.data_list.aGroup;//把后台封装好的简单Json格式赋给treeNodes
                var t = $("#treeDemo");
                $.fn.zTree.init(t, setting, treeNodes);
                $('#treeDemoinput').on('input', function(){
                    // 过滤数组
                    var _filterList = getCurIndex(treeNodes, 'name', $(this).val())
                    $.fn.zTree.init(t, setting, _filterList);
                })
                //console.log(data);
                //请求成功后处理函数
                // treeNodes = data.data_list.aGroup;//把后台封装好的简单Json格式赋给treeNodes
            }
        });
        // var t = $("#treeDemo");
        // t = $.fn.zTree.init(t, setting, treeNodes);
    }

    //分配TMK
    $("#tmk").on("click", function () {
        var ids = [];
        $("table>tbody>tr>td>div").each(function () {
            if ($(this).hasClass("layui-form-checked")) {
                var checkboxID = $(this).prev("input").attr("sutdent_id");
                ids.push(checkboxID);
            }
        })
        if (ids.length == 0) {
            layer.alert("至少选择一项");
        } else {
            var modal = '<div class="modal fade" id="data-modal" tabindex="1" role="dialog" aria-labelledby="modal-info-label">' +
                ' <div class="modal-dialog" role="document">' +
                ' <div class="modal-content">' +
                '<div class="modal-header state modal-info">' +
                '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>' +
                '</button>' +
                '<h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>' +
                '</div>' +
                ' <div class="modal-body" style="min-height: 150px;">' +
                '<div class="col-xs-12">' +
                ' <label class="col-sm-3 control-label" style="line-height: 34px;text-align: right">TMK:</label>' +
                '<div class="col-sm-9">' +
                '<input class="form-control" data-tmk-id="" id="select-picker" name="select-picker" type="text" placeholder="TMK">' +
                '</div>' +
                '</div>' +
                '</div>' +
                '<div class="modal-footer">' +
                '<button type="button" class="btn btn-info" id="surepass" data-dismiss="modal">保存</button>' +
                '<button type="button" class="btn btn-default" id="returnGroup" data-dismiss="modal">返回</button>' +
                '</div>' +
                '</div>' +
                '</div>' +
                '</div>';
            $("#modalbox").html("").html(modal);
            $('#data-modal').modal({
                keyboard: false,
                backdrop: false
            });
            $("#select-picker").focus(function () {
                $('#tmk-modal').modal({
                    keyboard: false,
                    backdrop: false
                });
            });
            $("#suretmk").on("click", function () {
                var zTree = $.fn.zTree.getZTreeObj("tmklist"),
                    nodes = zTree.getSelectedNodes(),
                    treeNode = nodes[0];
                console.log(treeNode);
                if (nodes.length == 0) {
                    alert("请先选择一个节点");
                    return;
                }
                $("#select-picker").val(treeNode.name).attr("data-tmk-id", treeNode.id);
            })
            $("#surepass").on("click", function () {
                $.ajax({
                    url: $("input[name='editTMK']").val(),
                    type: 'post',
                    data: {
                        student_ids: ids,
                        tmk_id: $("input[name='select-picker']").attr("data-tmk-id")
                    },
                    dataType: 'json',
                    success: function (data) {
                        console.log(data);
                        if (data.success == 1) {
                            console.log("!!!!!!")
                            location.reload();
                        } else {
                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            })
        }
    })
    //分配CC
    $("#cc").on("click", function () {
        var ids = [];
        $("table>tbody>tr>td>div").each(function () {
            if ($(this).hasClass("layui-form-checked")) {
                var checkboxID = $(this).prev("input").attr("sutdent_id");
                ids.push(checkboxID);
            }
        })
        console.info(ids);
        if (ids.length == 0) {
            layer.alert("至少选择一项");
        } else {
            var modal = '<div class="modal fade" id="data-modal" tabindex="1" role="dialog" aria-labelledby="modal-info-label">' +
                ' <div class="modal-dialog" role="document">' +
                ' <div class="modal-content">' +
                '<div class="modal-header state modal-info">' +
                '<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>' +
                '</button>' +
                '<h4 class="modal-title" id="modal-info-label"><i class="fa fa-info"></i></h4>' +
                '</div>' +
                ' <div class="modal-body" style="min-height: 150px;">' +
                '<div class="col-xs-12">' +
                ' <label class="col-sm-3 control-label" style="line-height: 34px;text-align: right">CC:</label>' +
                '<div class="col-sm-9">' +
                '<input class="form-control" id="select-picker" name="select-picker" type="text" placeholder="CC">' +
                '</div>' +
                '</div>' +
                '</div>' +
                '<div class="modal-footer">' +
                '<button type="button" class="btn btn-info" id="savecc" data-dismiss="modal">保存</button>' +
                '<button type="button" class="btn btn-default" id="returncc" data-dismiss="modal">返回</button>' +
                '</div>' +
                '</div>' +
                '</div>' +
                '</div>';
            $("#modalbox").html("").html(modal);
            $('#data-modal').modal({
                keyboard: false,
                backdrop: false
            });
            $("#select-picker").focus(function () {
                $('#cc-modal').modal({
                    keyboard: false,
                    backdrop: false
                });
            });
            $("#surecc").on("click", function () {
                var zTree = $.fn.zTree.getZTreeObj("cclist"),
                    nodes = zTree.getSelectedNodes(),
                    treeNode = nodes[0];
                console.log(treeNode);
                if (nodes.length == 0) {
                    alert("请先选择一个节点");
                    return;
                }
                $("#select-picker").val(treeNode.name).attr("data-cc-id", treeNode.id);
            })
            $("#savecc").on("click", function () {
                console.log($("input[name='editCC']").val())
                $.ajax({
                    url: $("input[name='editCC']").val(),
                    type: 'post',
                    data: {
                        student_ids: ids,
                        cc_id: $("input[name='select-picker']").attr("data-cc-id")
                    },
                    dataType: 'json',
                    success: function (data) {
                        console.log(data);
                        if (data.success == 1) {
                            console.log("!!!!!!")
                            location.reload();
                        } else {
                        }
                    },
                    complete: function () {
                    },
                    error: function () {

                    }
                });
            })
        }
    })
    //分配TMK渲染
    function getTmkListData() {
        var data_list;
        $.ajax({
            url: $("input[name='tmklist']").val(),
            type: 'post',
            async: false,
            dataType: 'json',
            success: function (data) {
                console.log(data)
                if (data.success == 1) {
                    data_list = data.data_list;
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
        return data_list;
    }
    //分配cc渲染
    function getCcListData() {
        var data_list;
        $.ajax({
            url: $("input[name='cclist']").val(),
            type: 'post',
            async: false,
            dataType: 'json',
            success: function (data) {
                console.log(data)
                if (data.success == 1) {
                    data_list = data.data_list;
                } else {
                }
            },
            complete: function () {
            },
            error: function () {

            }
        });
        return data_list;
    }

    $("form").submit(function (e) {
        //alert("Submitted");
    });
    var settingTmk = {
        view: {
            selectedMulti: false
        },
        edit: {
            enable: false
        },
        data: {
            keep: {
                parent: true,
                leaf: true
            },
            simpleData: {
                enable: true
            }
        }
    };
    var zNodesTmk = getTmkListData();
    $.each(zNodesTmk, function (i, item) {
//            item.isParent = true;
        item.name = item.full_name
//            item.Pid = item.id
    })
    $.fn.zTree.init($("#tmklist"), settingTmk, zNodesTmk);
    $('#tmklistinput').on('input', function(){
        // 过滤数组
        var _filterList = getCurIndex(zNodesTmk, 'name', $(this).val())
        $.fn.zTree.init($("#tmklist"), settingTmk, _filterList);
    })
    var settingCc = {
        view: {
            selectedMulti: false
        },
        edit: {
            enable: false
        },
        data: {
            keep: {
                parent: true,
                leaf: true
            },
            simpleData: {
                enable: true
            }
        }
    };
    var zNodesCc = getCcListData();
    $.each(zNodesCc, function (i, item) {
//            item.isParent = true;
        item.name = item.full_name
    })
    $.fn.zTree.init($("#cclist"), settingCc, zNodesCc);
    $('#cclistinput').on('input', function(){
        // 过滤数组
        var _filterList = getCurIndex(zNodesCc, 'name', $(this).val())
        $.fn.zTree.init($("#cclist"), settingCc, _filterList);
    })

    
    //数组去重
    Array.prototype.unique3 = function () {
        var res = [];
        var json = {};
        for (var i = 0; i < this.length; i++) {
            if (!json[this[i]]) {
                res.push(this[i]);
                json[this[i]] = 1;
            }
        }
        return res;
    }
    //批量修改
    var arrs = [];
    $("#more_change").click(function () {
        $("table>tbody>tr>td>div").each(function () {
            if ($(this).hasClass("layui-form-checked")) {
                var checkboxID = $(this).prev("input").attr("id");
                arrs.push(checkboxID);
            }
        })
        if (arrs.length == 0) {
            layer.alert("至少选择一项");
        } else {
            layer.open({
                type: 1
                , title: false //不显示标题栏
                , closeBtn: false
                , area: '300px;'
                , shade: 0.8
                , id: 'LAY_layuipro' //设定一个id，防止重复弹出
                , btn: ['保存', '取消']
                , moveType: 1 //拖拽模式，0或者1
                , content: '<div style="padding: 50px; line-height: 22px;  font-weight: 300;">' +
                $("#yuyue_modal").html() +
                '</div>'
                , success: function (layero) {
                    arrs = arrs.unique3();
                    var changeUrl = $("#more_change").attr("url");
                    //批量修改渲染接口
                    $.ajax({
                        url: changeUrl,
                        traditional: true,
                        type: 'POST',
                        dataType: 'json',
                        success: function (data) {
                            changeApply(data);//批量修改渲染
                        }
                    })
                    var select_data = {};
                    var btn = layero.find('.layui-layer-btn');
                    btn.css('text-align', 'center');
                    btn.find('.layui-layer-btn0').on("click", function () {
                        //console.log("#"+select_option)
                        if (!$("#LAY_layuipro>div>div.up_area").has("select")) {
                            var a = ".layui-layer-content #" + select_option;

                        } else {
                            var a = ".layui-layer-content #quickedit_field_" + select_option;
                        }
                        //console.log($(a).val())
                        select_data[select_option] = $(a).val();
                        if(select_option == 'student_attendance_status') {
                            select_data['teacher_attendance_status'] = $(a).val();
                        }
                        console.log(select_data);
                        var urlSubmit = $("#more_change").attr("urlSubmit");
                        //批量修改保存接口
                        $.ajax({
                            url: urlSubmit,
                            data: {
                                ids: arrs,
                                data: select_data
                            },
                            type: 'POST',
                            dataType: 'json',
                            success: function (data) {
                                if (data.success == 1) {
                                    $(".small").text("");
                                    $(".up_area").text("");
                                    layer.msg("修改成功");
                                    setTimeout(function () {
                                        window.location.reload();
                                    }, 3000);
                                } else {
                                    layer.msg("修改失败");
                                }
                            }
                        })
                    })
                }
            })
        }
    });
    var select_option_vals;
    //批量修改渲染
    function changeApply(data) {
        var str = "", strs = '';
        $.each(data, function (i, dataVal) {
            str += '<option value=' + dataVal.val + ' type=' + dataVal.type + '>' + dataVal.name + '</option>'
            if (dataVal.type == "text") {
                strs += '<div id="quickedit_field_' + dataVal.val + '" uitype="1" style="display:none;">'
                    + '<input type="text" tabindex="1" name="quickedit_value_' + dataVal.val + '" id="' + dataVal.val + '" value="" class="detailedViewTextBox">'
                    + '</div>'
            } else if (dataVal.type == "select") {
                strs += '<select id="quickedit_field_' + dataVal.val + '" tabindex="1811111" style="display:none;">'
                $.each(dataVal.data_list, function (n, listVal) {
                    strs += '<option value=' + listVal.dict_value + '>"' + listVal.cn_name + '"</option>'
                })
                strs += '</select>'
            }
        })
        $(".small").html(str);
        $(".up_area").html(strs);
        $(".small").change(function () {
            var selectedVal = $(this).find("option:selected").attr("value");
            var e = "#quickedit_field_" + selectedVal;
            $("div[id*='quickedit_field_']").css("display", "none");
            $("select[id*='quickedit_field_']").css("display", "none");
            $("#LAY_layuipro").find(e).fadeIn();
            select_option = selectedVal;
            select_element = e;
        })
        // console.log(select_option);
        $(".up_area>select").change(function () {
            var selectedVal_childs = $(this).find("option:selected").attr("value");
            console.log(selectedVal_childs);
            select_option_vals = selectedVal_childs;
        })
    }

    //批量删除
    var arr = [];
    $("#more_del").click(function () {
        $("table>tbody>tr>td>div").each(function () {
            if ($(this).hasClass("layui-form-checked")) {
                var checkboxID = $(this).prev("input").attr("id");
                arr.push(checkboxID);
            }
        })
        if (arr.length == 0) {
            layer.alert("至少选择一项");
        } else {
            layer.confirm('确定批量删除吗？', {
                btn: ['取消', '确定'] //按钮
            });
            //点击确定批量删除
            $(".layui-layer-dialog>.layui-layer-btn>a.layui-layer-btn1").click(function () {
                arr = arr.unique3();
                var delUrl = $("#more_del").attr("url"),
                    actions = $("#more_del").attr("actions");
                $.ajax({
                    url: delUrl,
                    data: {
                        ids: arr,
                        actions: actions
                    },
                    type: 'POST',
                    dataType: 'json',
                    success: function (data) {
                        if (data.success == 1) {
                            layer.msg("删除成功");
                            setTimeout(function () {
                                window.location.reload();
                            }, 3000);
                        } else {
                            layer.msg("删除失败");
                        }
                    }
                })
            })
        }
    })

    //删除
    $(".delete").click(function () {
        var delVal = $(this).attr("url"),
            keyId = $(this).attr("keyid"),
            actions = $(this).attr("actions");
        if(confirm("确定删除本条数据吗？")) {
            $.ajax({
                url: delVal,
                data: {
                    id: keyId,
                    actions: actions
                },
                type: 'POST',
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                    if (data.success == 1) {
                        layer.msg("删除成功");
                        setTimeout(function () {
                            window.location.reload();
                        }, 3000);
                    } else {
                        layer.msg("删除失败");
                    }
                }
            })
        }
    })
    //搜索-form表单提交
    $("#search").click(function () {
        $("input[name='now_page']").val($("input:focus").val());
        $("#courseList").submit();
    })
    $("#search").bind('keyup', function (event) {
        if (event.keyCode == "13") {
            $("input[name='now_page']").val($("input:focus").val());
            //回车执行查询
            $('#search').click();
        }
    })

    $("#excel").on('click', function () {
        var jsonData = $("form").serializeArray();
        $.ajax({
            url: $(this).attr('url'),
            data: jsonData,
            type: 'post',
            dataType: 'json',
            success: function (data) {
                if (data.success == 1) {
                    window.open(data.data);
                } else {

                }
            },
            complete: function () {
            },
            error: function () {

            }
        });

    });
</script>
<?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>
<button id="top" style="height: 50px;width: 50px;"></button></body>

</html>
